New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for phpdbg with fast code coverage #258
Conversation
🏆 (also it partially solves #241) |
*/ | ||
private static function startXdebug() | ||
{ | ||
if (!extension_loaded('xdebug')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should (imho) also check PHP_SAPI !== 'phpdbg'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Phpdbg is pointless when you use xdebux strategy. Did you meant to use or or and?
👍 Since phpdbg seems to be much faster than XDebug (and it is also a native part of PHP), how about making it a default interpreter for PHP 7.0+? If anyone is testing this, be aware that before PHP 7.0.0RC5, there is a bug in phpdbg coverage report when return types are used: php/php-src@6c61286. |
👍 Some Tester's tests are failing for me, I thing we should wait for final 7.0.0. In meantime:
|
You need RC4 to be able to run phpdbg and RC5 to make all tests OK.
Or removing entirely. It's currently not used anywhere.
Runner may use different interpreter than jobs. It's annoying to generate coverage now, because you need to write two long arguments (coverage + coverage-src). Feel free to add coverarage-strategy but the parameter must be optional. The autodetection is simple a will work OK for 99.9 % of people. |
Thinking about it – it will probably be even better to split |
Oh, I cloned from GitHub, there is no RC5 yet.
Hmm,
Can be detected in an |
7.0.0 RC5 is out. |
👍 Is there any drawback/issue that needs to be solved? |
Waiting for stable 7 at least. |
If anybody is willing to help – download the PR and run tests against latest PHP 7, last time I checked this one test was failing. Unfortunately I did not have the time to determine whether it is bug in tester or PHP 7. |
Well, I do not want to push on merging a feature with failing tests, however, I see no reason not to merge a feature for an unstable version of php into development branch. Nette is full of support for php7. |
Definitely 👍, that argument makes no sense to me. Btw. PHP 7 release is postponed at least until the end of november. |
RC5 was not failling, later is failing. I don't want to invest my time into bug hunting. It's not only about Tester code, but compiling next RC and setup environment... that's time consuming. That's the reason why I'm waiting for stable release. |
Ehm… now you can fix phpdbg before 7.0.0 released.
It will not start working unless someone will make it work. Waiting is pointless. The situation will only get worse. |
@JanTvrdik Please, delete the vulgar words. Anyway, if you promise me that you will care about phpdbg and you will solve reported bugs about it, I'll invest the time into it. |
I didn't want to bring emotions here. Still, the "at least" seems to be restrictive and impropper. :) That's all. |
@milo: Although I understand your approach which it makes sense for a library, unfortunately it's not that logical for a tool that is used to run tests. Especially when talking about php-next, which is pretty critical now as the GA is around the corner. And in meantime, PHPUnit has PHP 7 support (incl. phpdbg) for over a month now... |
@milo I can't promise that all bugs will be resolved before 7.0.0. I'm saying that they might be fixed. After the release you would need to learn how to time travel.
I don't. If you want your library to support PHP 7 you should always start working on that before PHP 7 is released not after. This is especially important for libraries which use low-level or uncommon APIs (such as Tester or Tracy). |
@@ -13,6 +13,11 @@ | |||
*/ | |||
class Collector | |||
{ | |||
const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about two Collector classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some common code, so you would need three classes – one for each strategy and one base class. The logic for deciding which strategy to use would probably end-up extracted outside of those classes in \Tester\Environment::setupCoverage.
To summarize – it would require more code but should be possible.
Ok so the tests fail on 7.0.0 as well. Stderr:
Ansi codes in output could be fixed with this patch src/Runner/ZendPhpDbgInterpreter.php:41
+ fwrite($pipes[0], "set colors 0\n");
+ |
Stderr: @JanTvrdik found it's actually fixed on php-7.0.1RC1 php/php-src@c1189ec Ansi codes: alternative fix for noninteractive mode which is what Job invokes src/Runner/ZendPhpDbgInterpreter.php:63
- return $this->path . ' -qrr ' . $this->arguments;
+ return $this->path . ' -qrrb ' . $this->arguments; Other than those bugs, are there any issues that would prevent getting this merged? |
a25ae37
to
8e0f3b3
Compare
PING |
@JanTvrdik Would you squash last commit into the 1st and fix Job test in this way? |
Ping @JanTvrdik |
What about this? dg@e0a9875 |
Just a note: you can be running PHPDBG SAPI while having XDebug enabled as well, but in that case XDebug is not what we want to use, ever, right? |
@dg Seems better. |
@milo why it seems better? It seems as a spagtheti code, badly testable, wired, ... |
It is only simplified, with fixed exception message. Still not sure about this #258 (comment) |
|
I don't see the reason for choosing the coverage strategy manually for now and I would wait for real-world issue. In that case, David's simplification seems OK to me. @JanTvrdik Would you add the version check and such simplifications? |
@milo done |
@@ -228,9 +230,6 @@ private function createRunner() | |||
/** @return string */ | |||
private function prepareCodeCoverage() | |||
{ | |||
if (!$this->interpreter->hasXdebug()) { | |||
throw new \Exception("Code coverage functionality requires Xdebug extension (used {$this->interpreter->getCommandLine()})"); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho, this should stay there with modified message. And as a workaround, ZendPhpDbgInterpreter::hasXDebug()
should return TRUE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't make any sense. PHPDBG may or may not have XDebug loaded, just like normal CLI/CGI SAPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ZendPhpDbgInterpreter::hasXDebug()
is used only for detection that Coverage is possible. I have a plan for refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JanTvrdik Or maybe better ... && !$this->interpreter instanceof ZendPhpDbgInterpreter
.
@JanTvrdik One note in code. I'm sorry I didn't noticed earlier. |
Everything related to |
Agree. |
d045331
to
038cbed
Compare
Support for phpdbg with fast code coverage
Thank you! |
@@ -62,7 +62,7 @@ public static function setupColors() | |||
{ | |||
self::$useColors = getenv(self::COLORS) !== FALSE | |||
? (bool) getenv(self::COLORS) | |||
: (PHP_SAPI === 'cli' && ((function_exists('posix_isatty') && posix_isatty(STDOUT)) | |||
: ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ((function_exists('posix_isatty') && posix_isatty(STDOUT)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is PHP_SAPI === 'phpdbg'
correct? PHP_SAPI is 'cli' when argument -qrrb -S cli
is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dg Handy when called phpdbg path/to/test.phpt
manually.
Awesome work guys! |
Most of critical phpdbg bugs are fixed since RC4, some bugs are however still present.
https://bugs.php.net/bug.php?id=70532
https://bugs.php.net/bug.php?id=70531
https://bugs.php.net/bug.php?id=70614